
<template>
  <div class="login">
    <el-form ref="loginForm" :model="loginForm" :rules="loginRules">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="loginForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="loginForm.password"></el-input>
      </el-form-item>
      <el-form-item label="验证码" prop="captcha">
        <el-input v-model="loginForm.captcha"></el-input>
        <img :src="captchaUrl" @click="refreshCaptcha" alt="验证码">
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElForm, ElFormItem, ElInput, ElButton } from 'element-plus'
import axios from 'axios';
import http from '../untils/http'

const loginForm = ref({
  username: '',
  password: '',
  captcha: ''
})

const loginRules = ref({
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' }
  ],
  captcha: [
    { required: true, message: '请输入验证码', trigger: 'blur' }
  ]
})
const allUser = async () => {
  const response = await http.get('/api/sys/user');
  console.log(response.data)
} 
const captchaUrl = ref('')

function refreshCaptcha() {
  // 刷新验证码的逻辑
    
}

function submitForm() {
  // 提交表单的逻辑
   allUser()
}
</script>

<style scoped>
.login {
  max-width: 400px;
  margin: 0 auto;
}
</style>
